<template>
  <div>
    <div>
      <div class="search">
        <el-form :inline="true" :model="form" class="demo-form-inline">
          <el-form-item>
            <el-button type="primary" @click="toadd">录入信息</el-button>
          </el-form-item>
          <el-form-item>
            <el-input v-model="params.userId" clearable placeholder="请输入用户编号" />
          </el-form-item>
          <el-form-item>
            <el-select v-model="params.status" clearable placeholder="请选择状态">
              <el-option label="通过" value="通过" />
              <el-option label="不通过" value="不通过" />
              <el-option label="未审核" value="未审核" />
            </el-select>
          </el-form-item>
          <el-form-item />
          <el-form-item>
            <el-button type="primary" @click="toxxx">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <!-- 第二行  表格 -->
    <div>
      <el-table :data="certification" style="width: 100%">
        <el-table-column type="index" :index="1" label="序号" />
        <el-table-column prop="realname" label="真实姓名" align:center />
        <el-table-column prop="userId" label="申请人编号" align:center />
        <el-table-column prop="applyTime" label="申请时间" align:center />

        <el-table-column prop="idCard" label="身份证号" align:center />
        <el-table-column label="身份证正面" align:center>
          <template v-slot="scope">
            <img :src="scope.row.idcardPhotoNegative" alt="">
          </template>
        </el-table-column>
        <el-table-column label="身份证反面" align:center>
          <template v-slot="scope">
            <img :src="scope.row.idcardPhotoPositive" alt="">
          </template>
        </el-table-column>
        <el-table-column prop="status" label="认证状态" align:center>
          <template v-slot="scope">
            <el-tag :type="scope.row.status == '通过' ? 'success' : scope.row.status == '不通过' ? 'danger' : 'info'">{{
              scope.row.status }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="bankCard" label="银行账户" align:center />
        <el-table-column label="操作" align:center>
          <template v-slot="scope">
            <!-- {{ scope.row }} -->
            <el-link type="primary" style="margin-right: 10px;" @click="changeitem(scope.row)">修改</el-link>
            <!-- <el-link type="info" v-if="scope.row.status == '通过'" @click="change(scope.row.id, '通过')">通过</el-link>
            <el-link type="danger" v-else @click="change(scope.row.id, '不通过')">不通过</el-link> -->
            <el-link type="text" style="margin-right: 10px;" @click="tochange(scope.row)">审核</el-link>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 模态框 -->
    <div>
      <!-- <el-button type="text" @click="dialog = true">点击打开 Dialog</el-button> -->

      <el-dialog title="审核信息" :visible.sync="dialog1" width="30%" :before-close="handleClose">
        <span>姓名：</span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialog1 = false">取 消</el-button>
          <el-button type="primary" @click="dialog1 = false">确 定</el-button>
        </span>
      </el-dialog>
    </div>
    <!-- 第三行 分页按钮 -->
    <div class="page" style="text-align: center;margin-top: 10px;">
      <el-pagination :current-page="currentPage4" :page-sizes="[5, 10, 15, 20]" :page-size="params.pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
        @current-change="handleCurrentChange" />
    </div>
    <!-- 录入和修改的抽屉 -->
  </div>
</template>
<script>
import { findAll } from '@/api/privilege'
import { get } from '@/utils/request.js'
export default {
  data() {
    return {
      params: {
        page: 1,
        pageSize: 10
      },
      certification: [],
      dialog1: false
    }
  },
  created() {
    this.findAll()
  },
  methods: {
    async findAll() {
      const res = await get('/certification/pageQueryCertificationApply', this.params)
      console.log(res)
      this.certification = res.data.list
    },
    toadd() {

    },
    async toxxx() {
      console.log(this.params, 'asdasd45621');
      for (const key in this.params) {
        if(!this.params[key]){
          delete this.params[key]
        }
      }
      this.findAll()
    },
    tochange(row) {
      this.dialog1 = true
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => { })
    }

  }
}
</script>
